package com.museum.controller;

import com.alibaba.fastjson.JSONObject;
import com.museum.base.BaseApiService;
import com.museum.base.BaseResponse;
import com.museum.controller.APi.OtherControllerAPI;
import com.museum.entity.DO.Grade;
import com.museum.entity.DO.Sort;
import com.museum.entity.DO.Year;
import com.museum.mapper.GradeMapper;
import com.museum.mapper.SortMapper;
import com.museum.mapper.YearMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author LB
 * @version 1.0
 * @date 2021/1/17 23:03
 */
@RestController
@RequestMapping("/other")
public class OtherController extends BaseApiService<JSONObject> implements OtherControllerAPI {
    @Autowired
    private YearMapper yearMapper;
    @Autowired
    private SortMapper sortMapper;
    @Autowired
    private GradeMapper gradeMapper;
    @Override
    public BaseResponse<JSONObject> getOthers() {
        List<Year> years = yearMapper.selectList(null);
        List<Sort> sorts = sortMapper.selectList(null);
        List<Grade> grades = gradeMapper.selectList(null);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("yearList",years);
        jsonObject.put("sortList",sorts);
        jsonObject.put("gradeList",grades);
        return setResultSuccess(jsonObject);
    }
}
